<?php
namespace App\Http\Controllers\Api;

use App\Model\OperationLogs;
use Illuminate\Http\Request;
use App\Model\ApiUser;

class AnchorController extends BaseController
{

    protected $model = null;
    /**
     * @param Request $request
     */
    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new ApiUser();
    }

    //主播审核
    public function anchorVerify(Request $request){
        $res = $this->model->anchorVerify($request->all());
        if($res['code'] != self::SUCCESS) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::USER, '主播审核');
        return $this->toJson(self::SUCCESS);
    }

    //主播取消认证
    public function anchorOff(Request $request){
        $res = $this->model->anchorOff($request->all());
        if($res['code'] != self::SUCCESS) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::USER, '主播取消认证');
        return $this->toJson(self::SUCCESS);
    }


    //主播列表
    public function anchorList(Request $request){
        $res = $this->model->anchorList($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

}
